#ifndef CONFIGWIDGET_H
#define CONFIGWIDGET_H
#include <QtWidgets>
#include <QDialog>
#include <QSpinBox>
#include <QToolButton>
#include <QLabel>
#include <QHBoxLayout>

#include "common_struct/common_struct.h"

#define SPEED_MIN -500
#define SPEED_MAX 500

//!MapParamWidget
class MapParamWidget : public QDialog
{
    Q_OBJECT
public:
    MapParamWidget(QDialog *parent=0);
    MapParamWidget(dvec2 LonLat, float distance=15000, QDialog *parent=NULL);
    ~MapParamWidget();

signals:
    emitMapParameter(dvec2 MapCenLonLat, float fDistance);

private slots:
    void getMapParameter();
    void setMapParameter(dvec2 CenLonLat, float fDistance);

private:
    dvec2 transferDMStoLonLat(const Position &Pos);
    Position transferLattoDMS(const dvec2 &LonLat);
    QLabel* m_MapLatitudeLabel;                 //地图中心纬度
    QLabel* m_MapLatLabel_Degree;
    QLabel* m_MapLatLabel_Minute;
    QLabel* m_MapLatLabel_Second;
    QSpinBox *m_MapLatEdit_Degree;
    QSpinBox *m_MapLatEdit_Minute;
    QSpinBox *m_MapLatEdit_Second;

    QLabel* m_MapLongitudeLabel;                //经度
    QLabel* m_MapLonLabel_Degree;
    QLabel* m_MapLonLabel_Minute;
    QLabel* m_MapLonLabel_Second;
    QSpinBox *m_MapLonEdit_Degree;              //经度
    QSpinBox *m_MapLonEdit_Minute;
    QSpinBox *m_MapLonEdit_Second;

    QLabel*      m_MapDisLabel;                 //距离
    QLineEdit*   m_MapDisEdit;
    QPushButton* OKButton;
    QPushButton* CancelButton;
    QVBoxLayout* mainLayout;

    dvec2 m_LonLat;
    Position m_Pos;
    float m_distance;
};

//!RadarParamWidget
class RadarParamWidget : public QDialog
{
    Q_OBJECT
public:
    RadarParamWidget(dvec2 Location, float DetectionDistance,
                    float DirectionAngle,float StartAngle, float EndAngle,
                    QDialog *parent=0);
    RadarParamWidget(RadarParamInfoStruct RadarParamInfo, QDialog *parent = 0);
    RadarParamWidget(Radar_Pos_Info_Param_t pRadarPosInfo, uint8_t RadarNum, QDialog *parent=0);
    ~RadarParamWidget();

signals:
    emitRadarParameter(RadarParamInfoStruct info);
    emitRadarParameter(dvec2, float, float, float,float, float);

private slots:
    void getRadarParameter();
    void setRadarParameter(RadarParamInfoStruct info);

private:
    dvec2 transferDMStoLonLat(const Position &Pos);
    Position transferLattoDMS(const dvec2 &LonLat);

    QPushButton* RadarLatitudeButton;
    QPushButton* RadarLongitudeButton;
    QPushButton* DetectionRangeButton;
    QPushButton* DirectionAngleButton;
    QPushButton* StartAngleButton;
    QPushButton* EndAngleButton;
    QPushButton* NorthOffsetButton;
    QLabel* RadarLatDegree_Label;
    QLabel* RadarLatMinute_Label;
    QLabel* RadarLatSecond_Label;
    QLabel* RadarLonDegree_Label;
    QLabel* RadarLonMinute_Label;
    QLabel* RadarLonSecond_Label;
    QSpinBox* RadarLatDegree_SpinBox;
    QSpinBox* RadarLatMinute_SpinBox;
    QSpinBox* RadarLatSecond_SpinBox;
    QSpinBox* RadarLatError_SpinBox;

    QSpinBox* RadarLonDegree_SpinBox;
    QSpinBox* RadarLonMinute_SpinBox;
    QSpinBox* RadarLonSecond_SpinBox;
    QSpinBox* RadarLonError_SpinBox;
    QLineEdit* DetectionRangeEdit;
    QLineEdit* DirectionAngleEdit;
    QLineEdit* StartAngleEdit;
    QLineEdit* EndAngleEdit;
    QLineEdit* NorthOffsetEdit;
    QToolButton* sendButton;
    QVBoxLayout* mainLayout;
    QVBoxLayout *leftLayout;
    QGridLayout *rightLayout;
    QHBoxLayout *groupLayout;
    QHBoxLayout *bottomLayout;

    Position m_Pos;
    RadarParamInfoStruct m_RadarInfo;
};

//!TargetController
class TrackerController : public QWidget
{
    Q_OBJECT
public:
    TrackerController(QWidget* parent = 0);
    TrackerController(TrackerContrallerStruct TrackerCtrlInfo, QWidget* parent = 0);
    ~TrackerController();

signals:
    emitTrackerCrtlInfo(TrackerContrallerStruct info);

private slots:
    void getTrackerCrtlInfo();

private:
    void fillColorList(QComboBox *ComboBox);
    //widgets
    QLabel* saveTrack_Label;
    QLabel* deleteTracker_Label;
    QLabel* dyeingTracker_Label;
    QLabel* selectSpeed_Label;
    QLabel* SpeedRangeMax_Label;
    QLabel* SpeedRangeMin_Label;

    QLineEdit* saveTrack_Edit;
    QLineEdit* deleteTrack_Edit;
    QLineEdit* dyeingTracker_Edit;
    QSpinBox *SpeedMin_SpinBox;
    QSpinBox *SpeedMax_SpinBox;
    QComboBox* color_Combox;
    QStringList colorNameList;
    QToolButton* sendButton;
    QToolButton* cancelButton;
    QHBoxLayout* buttongroup_Layout;

    QGroupBox* TrackerManager_GroupBox;
    QGroupBox* TrackSetting_GroupBox;
    QGridLayout* manager_Layout;
    QGridLayout* setting_Layout;
    QVBoxLayout *mainlayout;

    //data
    TrackerContrallerStruct m_infostr;
};

#endif // CONFIGWIDGET_H
